<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <metahttp-equiv="X-UA-Compatible"content="ie=edge">
        <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="button" value="减少" @click="sub">
        <h1 style="display: inline-block;">&nbsp;{{num}}&nbsp;</h1>
        <input type="button" value="增加" @click="add">
    </div>
    <script src="./js/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                num:0

            },
            methods:{
                add(){
                    if(this.num>=10){
                        alert("不能大于10")
                        return;
                    }
                    this.num++;
                },
                sub(){
                    if(this.num<=0){
                        alert("不能小于0")
                        return;
                    }
                    this.num--;
                }
            }
            
        })
    </script>
</body>

</html>